/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans.validation;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

/**
 *
 * @author guybrush
 */
public class AddressValidator implements Validator {

    

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        
        String str = (String)value;
        if(!str.matches("[0-9a-zA-Z ]++, [0-9]++"))   
            throw new ValidatorException(new FacesMessage("Invalid Characters"));
    }
}
